home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-secsta.ads < prev    next >
Text File  |  1996-01-30  |  4KB  |  87 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --               S Y S T E M . S E C O N D A R Y _ S T A C K                --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.12 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with System.Storage_Elements; use System.Storage_Elements;
  27. with System.Storage_Pools;    use System.Storage_Pools;
  28.  
  29. package System.Secondary_Stack is
  30.  
  31.    type Secondary_Stack_Pool is new Root_Storage_Pool with null record;
  32.  
  33.    function  Storage_Size (Pool : Secondary_Stack_Pool) return Storage_Count;
  34.  
  35.    procedure Allocate
  36.      (Pool         : in out Secondary_Stack_Pool;
  37.       Address      :    out System.Address;
  38.       Storage_Size : in     Storage_Count;
  39.       Alignment    : in     Storage_Count);
  40.  
  41.    procedure Deallocate
  42.      (Pool         : in out Secondary_Stack_Pool;
  43.       Address      : in     System.Address;
  44.       Storage_Size : in     Storage_Count;
  45.       Alignment    : in     Storage_Count);
  46.  
  47.    type Mark_Id is private;
  48.    --  Type used to mark the stack.
  49.  
  50.    procedure SS_Init (Stk : out Address; Size : Natural);
  51.    --  Initialize the secondary stack with a main stack of the given Size.
  52.    --  All further allocations which do not overflow the main stack will not
  53.    --  generate dynamic (de)allocation calls. If the main Stack overflows
  54.    --  a new chuck of at least the same size will be allocated and linked
  55.    --  to the previous chunk.
  56.    --
  57.    --  Note: the reason that Stk is passed is that SS_Init is called before
  58.    --  the proper interface is established to obtain the address of the
  59.    --  stack using System.Task_Specific_Data.Get_Sec_Stack_Addr.
  60.  
  61.    procedure SS_Free (Stk : Address);
  62.    --  Release the memory allocated for the Secondary Stack. That is to say,
  63.    --  all the allocated chuncks.
  64.  
  65.    function SS_Mark return Mark_Id;
  66.    --  Return the Mark corresponding to the current state of the stack
  67.  
  68.    procedure SS_Release (M : Mark_Id);
  69.    --  Restore the state of the stack corresponding to the mark M. If an
  70.    --  additional chunk have been allocated, it will never be freed during a
  71.  
  72.    generic
  73.       with procedure Put_Line (S : String);
  74.    procedure SS_Info;
  75.    --  Debugging procedure used to print out secondary Stack allocation
  76.    --  information. This procedure is generic in order to avoid a direct
  77.    --  dependance on a particular IO package.
  78.  
  79.    SS_Pool : Secondary_Stack_Pool;
  80.    --  the pool for the secondary stack
  81.  
  82. private
  83.  
  84.    type Mark_Id is new Integer;
  85.  
  86. end System.Secondary_Stack;
  87.